package com.xizi;

import java.util.concurrent.*;

class callableTest implements Callable<String> {
    @Override
    public String call() {
        try {
            String a = "戏子zzz";
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return "exception";
        }
    }


    public static void main(String[] args) {
        //创建线程池
        ThreadPoolExecutor tpe = new ThreadPoolExecutor(5, 10,
                100, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(5));

        Future<String> future = tpe.submit(new callableTest());
        try {
            System.out.println(future.get());
            tpe.shutdown();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        } finally {
        }
    }
}